{include file="../application/admin/view/common/header.html" /}


<!--main content start-->
<section class="main-content">


    <!--start page content-->

    <div class="row">

        <div class="col-md-12">
            <div class="panel panel-default collapsed">
                <div class="panel-heading">
                    <label for="name"
                           style="color: #666666;font-size: 16px;font-weight: normal;line-height: 34px;margin: 3px 0;margin-right: 25px;">状态:
                        <select id="select1" style="height: 34px;border:1px solid #e0e0e0;width: 150px; ">
                            <option value="0">全部</option>
                            <option value="1">待审核</option>
                            <option value="2">审核通过</option>
                            <option value="3">审核不通过</option>
                        </select>
                    </label>
                    <div class="float-m" style="display: inline-block;">
                        <label>日期范围:</label>
                        <input type="text" id="logmin" class="input-text Wdate"
                               style="width:100px;display: inline-block;">
                        -
                        <input type="text" id="logmax" class="input-text Wdate"
                               style="width:100px;display: inline-block;">
                    </div>
                    <div class="search-form">
                        <input type="text" class="form-control" placeholder="搜索企业名称/联系人/手机"/>
                        <button type="button" id="submit" class="btn-search"><i class="fa fa-search"></i></button>
                    </div>
                </div>
                <div class="panel-body">

                    <table class="table table-hover table-striped table-bordered" data-page-size="12"
                           data-filter=#filter>
                        <thead>
                        <tr>
                            <th>选择</th>
                            <th>ID</th>
                            <th>企业名称</th>
                            <th>联系人姓名</th>
                            <th>身份证号</th>
                            <th>证件有效期</th>
                            <th>营业执照</th>
                            <th>组织机构代码证</th>
                            <th>联系方式</th>
                            <th>支付宝账号</th>
                            <th>申请时间</th>
                            <th>状态</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>


                        </tbody>
                    </table>
                    <div class="pager" id="page" style="text-align: right;"></div>
                </div>
            </div>
        </div>
    </div><!--end row-->

    <!--end page content-->
</section>
<!--end main content-->


<!--Common plugins-->
<script src="_JS_/jquery.min.js"></script>
<script src="_JS_/jquery.base64.js"></script>
<script src="_JS_/jquery.cookie.js"></script>
<script src="_JS_/bootstrap.min.js"></script>
<script src="_JS_/jasny-bootstrap.min.js"></script>
<script src="_JS_/jquery.slimscroll.min.js"></script>
<script src="_JS_/jquery.nanoscroller.min.js"></script>
<script src="_JS_/metismenu.min.js"></script>
<script src="_JS_/float-custom.js"></script>
<script type="text/javascript" src="_JS_/layer/layer.js"></script>
<script type="text/javascript" src="_JS_/laypage/laypage.js"></script>
<script type="text/javascript" src="_JS_/laydata/laydate.js"></script>
<script type="text/javascript" src="_JS_/getMyDate.js"></script>
<!-- Page-Level Scripts -->
<script>

    $(function () {
        $("#page-title").html("企业认证管理");
        postfile(1);
    })

    function postfile(page) {
        var static = $("#select1").val();
        var username = $(".search-form input").val();
        var logmin = $("#logmin").val();
        var logmax = $("#logmax").val();
        $.ajax({
            type: 'GET',
            url: "{:url('api/authentication/authentication_enterprise')}",
            dataType: 'jsonp',
            jsonp: 'callback',
            data: {'page': page, 'static': static, 'username': username, 'logmin': logmin, 'logmax': logmax},
            beforeSend: function () {
                var index = layer.load(1, {
                    shade: [0.1, '#333333'] //0.1透明度的白色背景
                });
            },
            success: function (msg) {
                layer.closeAll();
                $("#authentication_management").addClass("active").children("ul").addClass("in");
                $("#authentication_enterprise").addClass("choose");
                if (msg.code == 200) {
                    var pages = Math.ceil(msg.data.count / 10);
                    $(".table tbody").html("");
                    if (msg.data.data.length > 0) {
                        for (var i = 0; i < msg.data.data.length; i++) {
                            var time = msg.data.data[i].time;
                            ltime = getMyDate(time * 1000);


                            var html = '<tr id="' + msg.data.data[i].id + '">';
                            html += '<td><input type="checkbox" name=""></td><td>' + msg.data.data[i].id + '</td>';
                            html += '<td>' + msg.data.data[i].company_name + '</td><td>' + msg.data.data[i].nick + '</td>';
                            html += '<td>' + msg.data.data[i].card + '</td><td>' + msg.data.data[i].validity_time + '</td>';
                            html += '<td><img width="100px;" src="/Images/company/' + msg.data.data[i].business_pic + '"></td>' +
                                '<td><img width="100px;" src="/Images/company/' + msg.data.data[i].code_pic + '"></td>';
                            html += '<td>' + msg.data.data[i].phone + '</td><td>' + msg.data.data[i].alipay + '</td>';
                            html += '<td>' + ltime + '</td>';
                            if (msg.data.data[i].static == 1) {
                                html += '<td class="td-status enable">待审核</td><td class="buttons td-manage">' +
                                    '<a class="btn table-btn goods_pass" onclick="goods_pass(this)" href="javascript:void(0);" title="通过">' +
                                    '<i class="fa fa-check"></i></a><a class="btn table-btn goods_nopass" onclick="goods_nopass(this)" href="#" title="不通过">' +
                                    '<i class="fa fa-times"></i></a>';
                            } else if (msg.data.data[i].static == 2) {
                                html += '<td class="td-status pass">审核通过</td><td class="buttons td-manage">';
                                                            } else if (msg.data.data[i].static == 3) {
                                html += '<td class="td-status disable">审核不通过</td><td class="buttons td-manage">';
                                                            }
                                                            html += '<a class="btn table-btn" onclick="enterprise_msg(this)" href="#" title="查看详情"><i class="fa fa-ellipsis-h"></i></a></td></tr>';
                                                            $(".table tbody").append(html);
                                                        }
                                                    }
                                                    //分页
                                                    $(".table").attr("pages", page);
                                                    laypage({
                                                        cont: 'page',
                                                        pages: pages,
                                                        curr: page,
                                                        jump: function (obj, first) {
                                                            if (!first) { //点击跳页触发函数自身，并传递当前页：obj.curr
                                postfile(obj.curr);
                                                            }
                                                        }
                                                    })
                                                } else {
                                                    layer.msg('获取信息不成功!', {icon: 5, time: 2000});
                                                }
                                            }
                                        })
                                    }
                                
                                    // 搜索
                                    $('#submit').click(function () {
                                        postfile(1);
                                    })
                                
                                    //回车键绑定搜索
                                    $(".search-form").keydown(function (event) {
                                        if (event.keyCode == 13) {
                                            postfile(1);
                                        }
                                    });
                                
                                    // 状态查询
                                    $("#select1").change(function () {
                                        postfile(1);
                                    });
                                
                                    //信息
                                    function enterprise_msg(obj) {
                                        var id = "#" + $(obj).parents('tr').attr('id');
                                        layer.open({
                                            type: 2,
                                            title: '企业认证信息',
                                            shadeClose: true,
                                            shade: 0.8,
                                            area: ['700px', '700px'],
                                            content: 'authentication_enterprise_msg.html' + id
                                        });
                                    }
                                
                                    /*通过审核*/
                                    function goods_pass(obj, id) {
                                        layer.confirm('确认通过审核吗？', function (index) {
                                            var id = $(obj).parents('tr').attr('id');
                                   //         var page_id = $(".laypage_curr").html();
                                            //此处请求后台程序，下方是成功后的前台处理……
                                            $.ajax({
                                                type: 'GET',
                                                url: "{:url('api/authentication/enterprise_pass')}",
                                                dataType: 'jsonp',
                                                jsonp: 'callback',
                                                data: {id: id},
                                                success: function (msg) {
                                                    if (msg.code == 200) {
                                                        postfile(1);
                                                 //       $(obj).parents("tr").find(".td-status").html('审核通过').addClass("pass").removeClass("enable");
                                                   //     $(obj).parent().find('.goods_nopass').remove();
                                                     //   $(obj).remove();
                                                        layer.msg('已通过审核!', {icon: 1, time: 1000});
                                                    } else {
                                                        layer.msg('系统出错，请稍后重试!', {icon: 5, time: 2000})
                                                    }
                                                }
                                
                                            });
                                        });
                                    }
                                
                                    /*不通过审核*/
                                    function goods_nopass(obj, id) {
                                        layer.confirm('确认不通过审核吗？', function (index) {
                                            var id = $(obj).parents('tr').attr('id');
                                     //       var page_id = $('.laypage_curr').html();
                                            //此处请求后台程序，下方是成功后的前台处理……
                                            layer.close(index);
                                            layer.prompt({title: '审核不通过原因', formType: 2}, function (text, index) {
                                                layer.close(index);
                                                $.ajax({
                                                    type: 'GET',
                                                    url: "{:url('api/authentication/enterprise_nopass')}",
                                                    dataType: 'jsonp',
                                                    jsonp: 'callback',
                                                    data: {id: id, 'result': text},
                                                    success: function (msg) {
                                                        if (msg.code == 200) {
                                                            postfile(1);
                                                 //           $(obj).parents("tr").find(".td-status").html('审核不通过').addClass("disable").removeClass("enable");
                                                   //         $(obj).parent().find('.goods_pass').remove();
                                                     //       $(obj).remove();
                                                            layer.msg('审核不通过!', {icon: 2, time: 1000});
                                                        } else {
                                                            layer.msg('系统错误，请稍后重试', {icon: 5, time: 2000})
                                                        }
                                                    }
                                                })
                                            });
                                        });
                                    }
                                
                                
                                    //日期范围限制
                                    var start = {
                                        elem: '#logmin',
                                        format: 'YYYY-MM-DD',
                                        min: '1970-01-01', //设定最小日期为当前日期
                                        max: laydate.now(), //最大日期
                                        istime: false,
                                        istoday: false,
                                        choose: function (datas) {
                                            end.min = datas; //开始日选好后，重置结束日的最小日期
                                            end.start = datas //将结束日的初始值设定为开始日
                                        }
                                    };
                                
                                    var end = {
                                        elem: '#logmax',
                                        format: 'YYYY-MM-DD',
                                        min: '1970-01-01',
                                        max: laydate.now(),
                                        istime: false,
                                        istoday: false,
                                        choose: function (datas) {
                                            start.max = datas; //结束日选好后，充值开始日的最大日期
                                        }
                                    };
                                    laydate(start);
                                    laydate(end);
                                
                                </script>
</body>
</html>